<?php
if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.')
{
	$host = substr($_SERVER['HTTP_HOST'], 4);
	header('Location: //' . $host . $_SERVER['REQUEST_URI'], true, 301);
	exit;
}

if(!empty($_SERVER['REDIRECT_URL']) && substr($_SERVER['REDIRECT_URL'], -1, 1) != '/' && (substr($_SERVER['REDIRECT_URL'], -4, 1) != '.' || substr($_SERVER['REDIRECT_URL'], -3, 1) != '.'))
{
	$path = $_SERVER['REDIRECT_URL'] . '/';
	$query = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
	header('Location: //' . $_SERVER['HTTP_HOST'] . $path . $query, true, 301);
	exit;
}

defined('YII_DEBUG') or define('YII_DEBUG', false);
header('Content-Type:text/html;charset=utf-8');
require_once(dirname(__FILE__) . '/framework/yii.php');
Yii::createWebApplication(dirname(__FILE__) . '/protected/config/main.php')->run();